package com.swipemaster.levels;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

import android.app.Activity;

import com.google.gson.Gson;

/**
 * Loads level object from a file.
 */
public class LevelLoader
{
	public static Level load(String filename, Activity activity)
	{
		String json = null;
		try
		{
			FileInputStream fis = activity.openFileInput(filename); 
			InputStreamReader in = new InputStreamReader(fis);
			BufferedReader reader = new BufferedReader(in);
			json = reader.readLine();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		Gson gson = new Gson();
		return gson.fromJson(json, Level.class);
	}
}
